#include "ls_time.h"

#include "my_time/my_time.h"

/**
 * @brief time define
 * 
 */
#define HOUR_OF_DAY (24)
#define MIN_OF_HOUR (60)
#define MIN_OF_DAY  (HOUR_OF_DAY * MIN_OF_HOUR)
#define SEC_OF_MIN  (60)
#define SEC_OF_HOUR (MIN_OF_HOUR * SEC_OF_MIN)
#define SEC_OF_DAY  (SEC_OF_HOUR * HOUR_OF_DAY)

/**
 * @brief time zone difference
 * 
 */
uint16_t g_zone_time_stamp_buffer[] = {
    [ZONE_UTC] = 0,
    [ZONE_CST] = 8 * SEC_OF_HOUR,
};

/**
 * @brief timeStamp to timeString
 * 
 * @param time_stamp time stamp of second
 * @param zone zone info
 * @return char* 
 */
char* to_time_string(uint32_t time_stamp, zoneinfo zone)
{
    static char buf[30] = {0};
    memset(buf, 0, sizeof(buf));

    struct rtc_time tm;

    uint32_t ts = time_stamp + g_zone_time_stamp_buffer[zone];

    to_tm(ts, &tm);

    sprintf(buf, "%d-%d-%d %02d:%02d:%02d", \
            tm.tm_year, tm.tm_mon, tm.tm_mday, \
            tm.tm_hour, tm.tm_min, tm.tm_sec);

    return buf;
}

uint32_t to_time_stamp(const char* time_string, zoneinfo zone)
{
    return 0;
}
